<?php
session_start();

require_once("../database.include.php");

	$username=$_GET["username"];
				
    $sql = "SELECT `name`, `description` FROM `group` 
    WHERE `name` IN (SELECT `group_name` FROM `group_user` WHERE `user_name` = '" . $username . "')
    ORDER BY `name`";
    
    echo "<input type='hidden' id='selGroup' value=''>";
    echo "<table border='1'><tr><td>Select</td><td>Group Name</td><td>Group Description</td></tr>";
    foreach ($conn->query($sql) as $row) {
    	echo "<tr>";
    	echo "<td><input type='radio' name='delgroup' id='delgroup' value='" . $row['name'] . "' 
    		onclick=document.getElementById('selGroup').value='" . $row['name'] . "'></td>";
        echo "<td>" . $row['name'] . "</td>";
        echo "<td>" . $row['description'] . "</td>";
        echo "</tr>";
    }
    echo "</table>";
    echo "<button onclick='deleteGroup();'>Delete Group</button> &nbsp; <button onclick='showDeleteGroup();'>Hide</button>"
?>
